// 引入mongoose模块
const mongoose = require('mongoose')
// 连接本地数据库
mongoose.connect('mongodb://localhost/blog')

// 定义数据模型
const articleSchema = mongoose.Schema({
  title: String,
  author: String,
  category: String,
  add_time: String,
  add_time_yd: String,
  visits: Number,
  intro_content: String,
  content: String,
  img: String,
  img_cates: String,
  dianzan: Number
}, { collection: 'articles' })
// 上面第二个参数指定到数据库的articles表中取数据

// 导出model模块
const Article = module.exports = mongoose.model('article', articleSchema)
